<?php
include '../Module/OrganizationModule.php';
$OrModule=new OrganizationModule();
if(isset($_REQUEST["action"])){
    switch ($_REQUEST["action"]){
        case"add":
            $_type		=isset($_REQUEST["_type"])?$_REQUEST["_type"]:"";
            $name		=isset($_REQUEST["name"])?EndcodeStr($_REQUEST["name"]):"";
            $briefname		=isset($_REQUEST["briefname"])?EndcodeStr($_REQUEST["briefname"]):"";
            $website		=isset($_REQUEST["website"])?EndcodeStr($_REQUEST["website"]):"";
            $type		=isset($_REQUEST["type"])?EndcodeStr($_REQUEST["type"]):"";
            $phone		=isset($_REQUEST["phone"])?EndcodeStr($_REQUEST["phone"]):"";
            $fax		=isset($_REQUEST["fax"])?EndcodeStr($_REQUEST["fax"]):"";
            $address		=isset($_REQUEST["address"])?EndcodeStr($_REQUEST["address"]):"";
            $country		=isset($_REQUEST["country"])?EndcodeStr($_REQUEST["country"]):"";
            $nation		=isset($_REQUEST["nation"])?EndcodeStr($_REQUEST["nation"]):"";
            $des		=isset($_REQUEST["des"])?EndcodeStr($_REQUEST["des"]):"";
            if($OrModule->insertOrganization($_type,$name,$briefname,$website,$type,$phone,$fax,$address,$country,$nation,$des)){
                echo "true";
            }else{
                echo "Lỗi rồi<br/>".$OrModule->error;
            }
            break;
        case"edit":
            $_type		=isset($_REQUEST["_type"])?$_REQUEST["_type"]:"";
            $id                 =isset($_REQUEST["id"])?$_REQUEST["id"]:"";
            $name		=isset($_REQUEST["name"])?EndcodeStr($_REQUEST["name"]):"";
            $briefname		=isset($_REQUEST["briefname"])?EndcodeStr($_REQUEST["briefname"]):"";
            $website		=isset($_REQUEST["website"])?EndcodeStr($_REQUEST["website"]):"";
            $type		=isset($_REQUEST["type"])?EndcodeStr($_REQUEST["type"]):"";
            $phone		=isset($_REQUEST["phone"])?EndcodeStr($_REQUEST["phone"]):"";
            $fax		=isset($_REQUEST["fax"])?EndcodeStr($_REQUEST["fax"]):"";
            $address		=isset($_REQUEST["address"])?EndcodeStr($_REQUEST["address"]):"";
            $country		=isset($_REQUEST["country"])?EndcodeStr($_REQUEST["country"]):"";
            $nation		=isset($_REQUEST["nation"])?EndcodeStr($_REQUEST["nation"]):"";
            $des		=isset($_REQUEST["des"])?EndcodeStr($_REQUEST["des"]):"";
            if($OrModule->updateOrganization($_type,$id,$name,$briefname,$website,$type,$phone,$fax,$address,$country,$nation,$des)){
                echo "true";
            }else{
                echo "Lỗi rồi<br/>".$OrModule->error;
            }
            break;
        case"delete":
            $_type		=isset($_REQUEST["_type"])?$_REQUEST["_type"]:"";
            $id                 =isset($_REQUEST["id"])?$_REQUEST["id"]:"";
            if($OrModule->deleteOrganization($_type,$id)){
                echo "Delete Success.";
                JO_location();
                break;
            }else{
                echo "Lỗi rồi<br/>".$OrModule->error;
            }
            break;
    }    
}
?>